package org.batyrov.equery.action.admin;

import org.batyrov.equery.action.BaseAction;
import org.batyrov.equery.action.Const;
import org.batyrov.equery.bean.Window;
import org.batyrov.equery.bean.Service;
import java.util.Collection;

/**
 * Created by IntelliJ IDEA.
 * User: admin
 * Date: 13.09.2009
 * Time: 19:21:43
 * To change this template use File | Settings | File Templates.
 */
public class GetWindow extends BaseAction{

    private long id = -1;
    private Window window;
    private Collection<Service> services;

    public Collection<Service> getServices() {
        return services;
    }

    public void setServices(Collection<Service> services) {
        this.services = services;
    }

    public long getId() {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public Window getWindow() {
        return window;
    }

    public void setWindow(Window window) {
        this.window = window;
    }

    @Override
    public String execute() throws Exception {
        super.execute();
        window = em.find(Window.class, id);
        services = dao.getAllService();
        if (window != null)
            services.removeAll(window.getServices());
        return Const.SUCCESS;
    }
}
